﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<%@ Import Namespace="Tencent.OA.ACM.Entity" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeaderPlaceHolder" runat="server">
<script type="text/javascript" language="javascript" src="<%=this.Url.Content("~/content/Scripts/MicrosoftAjax.js") %>"></script>
<script type="text/javascript" language="javascript" src="<%=this.Url.Content("~/content/Scripts/MicrosoftMvcValidation.js") %>"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="mainContainerPlaceHolder" runat="server">
    <div class="title">
        系统信息 -- 缓存重建
    </div>
    <ul id="tags" class="tags">
        <li><a href='<%=this.Url.Content("~/Setting/Index") %>'>班车属性</a></li>
        <li><a href='<%=this.Url.Content("~/Setting/City") %>'>城市信息</a></li>
         <li ><a href="<%=this.Url.Content("~/Setting/Vehicle") %>">穿梭车辆</a></li>
         <li class="selectTag"><a href="javascript:void(0);">缓存重建</a></li>
        <%-- <span class="bt">系统信息 -- 班车类型</span>--%>
    </ul>
    <div class="tagCon">
        <div id="tagContent2" class="tagContent ">
        </div>
    </div>
    <%-- <div class="title ">
        统计报表
    </div>--%>
    <!--列表查询two-->
    <%--<div class="list_title">
        <div class="pag_right">            
        </div>
        <div style="padding-top: 6px;">
           
        </div>
    </div>--%>
    <div class="dv_refresh_title">
        缓存重建功能帮助您重新生成系统缓存，保持系统数据最新。&nbsp;&nbsp;
        <input type="button" id="btn_run" value="立即运行" onclick="runClear();" />
        <div class="refreshing" id="refreshing">
            正在运行缓存重建，请稍候...
        </div>
    </div>
    <div class="dv_refresh_log" id="dv_refresh_log">
    </div>
    <div id="dv_progress" style="display: none;">
        完成进度：
        <div id="progress_bar" class="progress_bar">
        <div id="progress_bar_dis" class="progress_bar_dis">&nbsp;</div>
        </div>
        完成数：<span id="progressInfo"></span>       
    </div>
    <div style="display: none;">
        <img src="<%=this.Url.Content("~/Content/Images/success.png") %>" />
        <img src="<%=this.Url.Content("~/Content/Images/failed.png") %>" />
        <iframe nam="ifr_task" id="ifr_task" src="#" style="height: 0; width: 0px;"></iframe>
    </div>
    

    <script language="javascript" type="text/javascript">
        var reqUrl='<%=this.Url.Content("~/RunClearCache.ashx") %>';
        var taskCount;
        //var curTask=0;
        var failure=0;
        //运行缓存重建
        function runClear() {
            $("#refreshing").fadeIn('slow');
            $("#btn_run").attr("disabled", "disabled");
            window.frames[0].src=reqUrl;
            document.getElementById("ifr_task").src=reqUrl;
            $("#dv_progress").fadeIn('slow');
            $("#dv_refresh_log").html('');
            failure=0;
            if(taskCount>0){
                setProgressBar(0);
            }
        }
        //设置总数
        function setWorkCount(num) {
            taskCount=num;
            appendProgress("开始重建","dv_task_section");
        }
        //设置进度
        function setWorkName(workName,workIndex,workResult) {            
            var css=workResult?"success_dv":"failed_dv";
            var img=workResult?"success.png":"failed.png";
            failure+=workResult?0:1;
            var  html='正在重建:&nbsp;' 
                    + workName;  
             $("#progressInfo").html(workIndex +"/"+ taskCount);               
            appendProgress(html,css);            
            setProgressBar(workIndex); 
             if(workIndex % 100 ==0){
                $("#dv_refresh_log").html('');
                appendProgress("开始重建","dv_task_section");
            }          
        }
        //完成
        function complate(){
            $("#refreshing").fadeOut('slow');
            $("#btn_run").attr("disabled", "");
            $("#progressInfo").append("，失败数目："+failure+"。");  
            appendProgress("重建完成！","dv_task_section");    
        }
        function appendProgress(text,css){
            $("#dv_refresh_log").append("<div class="+css+">"+text+'</div>');
            document.all.dv_refresh_log.scrollTop=document.all.dv_refresh_log.scrollHeight;
        }
        function setProgressBar(taskDo){
            var proValue=(taskDo)*100/taskCount;
            if(proValue>=100)
                proValue=100;
            document.getElementById("progress_bar_dis").style.width=proValue+"%";
        }
    </script>

</asp:Content>
